package cj.web.marriage.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.marriage.domain.YYWeddingPhoto;

/**
 * 
 * @author 
 *
 */
@DAO
public interface YYWeddingPhotoDAO{
	
	@SQL("SELECT * FROM YYWeddingPhoto WHERE deleteFlag=1 #if(:t.sellerName!=''){ AND sellerName LIKE '%##(:t.sellerName)%' } ORDER BY stickAt DESC,updateAt DESC LIMIT :t.start,:t.length ")
    List<YYWeddingPhoto> query(@SQLParam("t") YYWeddingPhoto yYWeddingPhoto);
	
	@SQL("SELECT count(1) FROM YYWeddingPhoto WHERE deleteFlag=1 #if(:t.sellerName!=''){ AND sellerName LIKE '%##(:t.sellerName)%' } ")
    int querysize(@SQLParam("t") YYWeddingPhoto yYWeddingPhoto);
    
    @SQL("SELECT * FROM YYWeddingPhoto WHERE id=:1 ")
    YYWeddingPhoto queryById(int id);
    
    @SQL("INSERT INTO YYWeddingPhoto (img,sellerName,price,area,tel,address,type,state,descs,deleteFlag,createAt,createUser,updateAt,updateUser) VALUES (:t.img,:t.sellerName,:t.price,:t.area,:t.tel,:t.address,:t.type,:t.state,:t.descs,1,now(),:t.createUser,now(),:t.updateUser)")
	void create(@SQLParam("t") YYWeddingPhoto yYWeddingPhoto);
	
	@SQL("UPDATE YYWeddingPhoto SET img=:t.img,sellerName=:t.sellerName,price=:t.price,area=:t.area,tel=:t.tel,address=:t.address,descs=:t.descs,updateAt=now(),updateUser=:t.updateUser WHERE id=:t.id")
	void update(@SQLParam("t") YYWeddingPhoto yYWeddingPhoto);
    
    @SQL("UPDATE YYWeddingPhoto SET deleteFlag=0,updateAt=now() WHERE id=:1 ")
    void deleteById(int id);
    
    @SQL("UPDATE YYWeddingPhoto SET state=:2,updateAt=now() WHERE id=:1 ")
    void updateStateById(int id,int state);
    
    @SQL("UPDATE YYWeddingPhoto SET stickAt=NOW() WHERE id=:1")
	void stick(int id);
}